package com.syni.mdd.sjb.common.datatreaure.listen.order;

import com.syni.mdd.sjb.common.component.mybatis.dxshapp.entity.DxshAppServiceOrder;
import com.syni.mdd.sjb.common.component.mybatis.dxshapp.entity.DxshAppServices;
import com.syni.mdd.sjb.common.component.utils.common.utils.DateTimeUtils;
import com.syni.mdd.sjb.common.datatreaure.service.DxshAppServiceOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class MddDataBankOrderListener implements ApplicationListener<MddDataBankOrderEvent> {

    @Autowired
    DxshAppServiceOrderService dxshAppServiceOrderService;
    @Override
    public void onApplicationEvent(MddDataBankOrderEvent mddDataBankOrderEvent) {
        DxshAppServices dxshAppServices = mddDataBankOrderEvent.getDxshAppServices();
        //添加两个后置任务（1小时，7天）
        DxshAppServiceOrder dxshAppServiceOrder = mddDataBankOrderEvent.getDxshAppServiceOrder();
        Date firstInfoTime = DateTimeUtils.addMinutes(DateTimeUtils.converLocalDateTimeToDate(dxshAppServiceOrder.getNewTime()),1);
        String suffix = "_1";
        dxshAppServiceOrderService.addInfo(suffix,firstInfoTime,dxshAppServiceOrder,dxshAppServices);
        suffix = "_2";
        Date secondTime = DateTimeUtils.addDay(DateTimeUtils.converLocalDateTimeToDate(dxshAppServiceOrder.getNewTime()),7);
        dxshAppServiceOrderService.addInfo(suffix,secondTime,dxshAppServiceOrder,dxshAppServices);
    }




}
